#ifndef REQUEST_H
#define REQUEST_H

#include <cmath>

/**
 *  Request Class
 *  A Request submitted by the passenger with where the passenger depart and where to arrive
 */

class Request
{
public:

    /**
     *  Value for a floor number hich means unavaliable
     */
    static const int FLOOR_NONE = -1;

    /**
     *  Directions which the elevator will go
     */
    enum DIRECTION{DIRECTION_UP, DIRECTION_DOWN, DIRECTION_NONE};

    /**
     *  Construct a Request Class with the 'from' and 'to' param
     */
    Request(int f,int t){
        departure=f;
        destination=t;
    }

    /**
     *  Mark the departure floor of the Request to FLOOR_NONE,
     *  this usually means that the departure floor of the Request has been arrived.
     */
    void unsetDeparture(){
        departure=FLOOR_NONE;
    }

    /**
     *  Mark the destination floor of the Request to FLOOR_NONE,
     *  define it but seemed that it's useless now.
     */
    void unsetDestination(){
        destination=FLOOR_NONE;
    }

    /**
     *  Get the Departure floor from 1 to +INF and FLOOR_NONE.
     */
    int getDeparture(){
        return departure;
    }

    /**
     *  Get the Destination floor from 1 to +INF and FLOOR_NONE.
     */
    int getDestination(){
        return destination;
    }

    /**
     *  Get the the length(floor count) from departure floor to destiination floor.
     */
    int getLength(){
        return std::fabs(departure-destination);
    }

    /**
     *  Get the the DIRECTION from departure floor to destiination floor.
     */
    DIRECTION getDirection(){
        if(departure>destination){
            return DIRECTION_DOWN;
        }else if(departure<destination){
            return DIRECTION_UP;
        }else{
            return DIRECTION_NONE;
        }
    }

    /**
     *  Get the the DIRECTION from departure floor to the floor passed.
     */
    DIRECTION getDirectionToDeparture(int floor){
        if(departure<floor){
            return DIRECTION_DOWN;
        }else if(departure>floor){
            return DIRECTION_UP;
        }else{
            return DIRECTION_NONE;
        }
    }

    /**
     *  Get the the DIRECTION from destination floor to the floor passed.
     */
    DIRECTION getDirectionToDestination(int floor){
        if(floor<destination){
            return DIRECTION_DOWN;
        }else if(floor>destination){
            return DIRECTION_UP;
        }else{
            return DIRECTION_NONE;
        }
    }

private:
    int  departure;     //!< Variable to store the departure floor
    int  destination;   //!< Variable to store the destination floor
};

#endif // REQUEST_H
